const http = require("http");
const fs = require("fs");
const path = require("path");
http.createServer((req, res) => {
    let filePath = path.join(__dirname, "demo1.html");
    fs.readFile(filePath, (err, data) => {
        if (err) {
            console.log(err);
        }
        else {
            res.end(data.toString());
            // 只能写到回调函数里
        }
        // res.end();不会先执行
    })

}).listen(8080);
//读取完了，执行回调函数
console.log("server is listening 8080");